<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Flow: net_flow/asio/node.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Flow<span id="projectnumber">&#160;2.0.0</span>
   </div>
   <div id="projectbrief">Flow project: Full implementation reference.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_460afd45d0ec637b1427e0e06a6fbcf7.html">net_flow</a></li><li class="navelem"><a class="el" href="dir_183f5ca7bfa2ee923b1b08301562c36a.html">asio</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">node.cpp</div></div>
</div><!--header-->
<div class="contents">
<a href="asio_2node_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/* Flow</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> * Copyright 2023 Akamai Technologies, Inc.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> *</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> * Licensed under the Apache License, Version 2.0 (the</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> * &quot;License&quot;); you may not use this file except in</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span><span class="comment"> * compliance with the License.  You may obtain a copy</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="comment"> * of the License at</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="comment"> *</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span><span class="comment"> *   https://www.apache.org/licenses/LICENSE-2.0</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="comment"> *</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="comment"> * Unless required by applicable law or agreed to in</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span><span class="comment"> * writing, software distributed under the License is</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span><span class="comment"> * distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span><span class="comment"> * CONDITIONS OF ANY KIND, either express or implied.</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="comment"> * See the License for the specific language governing</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span><span class="comment"> * permissions and limitations under the License. */</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span><span class="comment"></span> </div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="comment">/// @file</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="comment"></span> </div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="preprocessor">#include &quot;<a class="code" href="asio_2node_8hpp.html">flow/net_flow/asio/node.hpp</a>&quot;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#include &quot;<a class="code" href="asio_2peer__socket_8hpp.html">flow/net_flow/asio/peer_socket.hpp</a>&quot;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &quot;<a class="code" href="asio_2server__socket_8hpp.html">flow/net_flow/asio/server_socket.hpp</a>&quot;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span> </div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"><a class="line" href="namespaceflow_1_1net__flow.html">   24</a></span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespaceflow_1_1net__flow_1_1asio.html">flow::net_flow::asio</a></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span>{</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span> </div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span><span class="comment">// Implementations.  For Node code pertaining to individual Server_sockets and Peer_sockets see their .cpp files.</span></div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span> </div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1asio_1_1Node.html#a7db28ab33b1a9afcdcd1884e08f33bee">   29</a></span><a class="code hl_function" href="classflow_1_1net__flow_1_1asio_1_1Node.html#a7db28ab33b1a9afcdcd1884e08f33bee">Node::Node</a>(<a class="code hl_class" href="classflow_1_1log_1_1Logger.html">log::Logger</a>* logger_ptr, <a class="code hl_typedef" href="namespaceflow_1_1util.html#ac3e89a8a271b0ddc76ac2a0ce488dea4">util::Task_engine</a>* target_async_task_engine,</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span>           <span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow_1_1util.html#af1b28edb7bad743c1c77f6b982cc3196">util::Udp_endpoint</a>&amp; low_lvl_endpoint,</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span>           <a class="code hl_class" href="classflow_1_1net__flow_1_1Net__env__simulator.html">Net_env_simulator</a>* net_env_sim, <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a>* err_code,</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span>           <span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node__options.html">Node_options</a>&amp; opts) :</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span>  net_flow::<a class="code hl_class" href="classflow_1_1net__flow_1_1asio_1_1Node.html">Node</a>(logger_ptr, low_lvl_endpoint, net_env_sim, err_code, opts),</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>  m_target_task_engine(target_async_task_engine) <span class="comment">// May be null.</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span>{</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Starting net_flow::asio::Node [&quot;</span> &lt;&lt; <span class="keyword">static_cast&lt;</span><span class="keywordtype">void</span>*<span class="keyword">&gt;</span>(<span class="keyword">this</span>) &lt;&lt; <span class="stringliteral">&quot;]; &quot;</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span>                <span class="stringliteral">&quot;saving target Task_engine [&quot;</span> &lt;&lt; <span class="keyword">static_cast&lt;</span><span class="keywordtype">void</span>*<span class="keyword">&gt;</span>(target_async_task_engine) &lt;&lt; <span class="stringliteral">&quot;].&quot;</span>);</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span>}</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span> </div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1asio_1_1Node.html#a778ffa52a73f455142da9497ca10734d">   40</a></span><a class="code hl_typedef" href="namespaceflow_1_1util.html#ac3e89a8a271b0ddc76ac2a0ce488dea4">util::Task_engine</a>* <a class="code hl_function" href="classflow_1_1net__flow_1_1asio_1_1Node.html#a778ffa52a73f455142da9497ca10734d">Node::async_task_engine</a>()</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span>{</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span>  <span class="comment">// Not thread-safe against set_async_task_engine().  Discussed in my doc header.</span></div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span>  <span class="keywordflow">return</span> <a class="code hl_variable" href="classflow_1_1net__flow_1_1asio_1_1Node.html#a5b688a4071b8ad58a776de8d3816b757">m_target_task_engine</a>;</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span>}</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1asio_1_1Node.html#a0e6b29f0ae35a832b0c3c75cf0b577ae">   46</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1asio_1_1Node.html#a0e6b29f0ae35a832b0c3c75cf0b577ae">Node::set_async_task_engine</a>(<a class="code hl_typedef" href="namespaceflow_1_1util.html#ac3e89a8a271b0ddc76ac2a0ce488dea4">util::Task_engine</a>* target_async_task_engine)</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span>{</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span>  <span class="comment">// Not thread-safe against m_target_task_engine access.  Discussed in my doc header.</span></div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno">   49</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Object [&quot;</span> &lt;&lt; <span class="keyword">this</span> &lt;&lt; <span class="stringliteral">&quot;] has been assigned an Task_engine at [&quot;</span> &lt;&lt; target_async_task_engine &lt;&lt; <span class="stringliteral">&quot;]; &quot;</span></div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>                <span class="stringliteral">&quot;currently [&quot;</span> &lt;&lt; <span class="keyword">static_cast&lt;</span><span class="keywordtype">void</span>*<span class="keyword">&gt;</span>(<a class="code hl_variable" href="classflow_1_1net__flow_1_1asio_1_1Node.html#a5b688a4071b8ad58a776de8d3816b757">m_target_task_engine</a>) &lt;&lt; <span class="stringliteral">&quot;].&quot;</span>);</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>  <a class="code hl_variable" href="classflow_1_1net__flow_1_1asio_1_1Node.html#a5b688a4071b8ad58a776de8d3816b757">m_target_task_engine</a> = target_async_task_engine;</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>}</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span> </div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>} <span class="comment">// namespace flow::net_flow::asio</span></div>
<div class="ttc" id="aasio_2node_8hpp_html"><div class="ttname"><a href="asio_2node_8hpp.html">node.hpp</a></div></div>
<div class="ttc" id="aasio_2peer__socket_8hpp_html"><div class="ttname"><a href="asio_2peer__socket_8hpp.html">peer_socket.hpp</a></div></div>
<div class="ttc" id="aasio_2server__socket_8hpp_html"><div class="ttname"><a href="asio_2server__socket_8hpp.html">server_socket.hpp</a></div></div>
<div class="ttc" id="aclassflow_1_1log_1_1Logger_html"><div class="ttname"><a href="classflow_1_1log_1_1Logger.html">flow::log::Logger</a></div><div class="ttdoc">Interface that the user should implement, passing the implementing Logger into logging classes (Flow'...</div><div class="ttdef"><b>Definition:</b> <a href="log_8hpp_source.html#l01280">log.hpp:1284</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Net__env__simulator_html"><div class="ttname"><a href="classflow_1_1net__flow_1_1Net__env__simulator.html">flow::net_flow::Net_env_simulator</a></div><div class="ttdoc">Objects of this class can be fed to Node to make it internally simulate network conditions like loss,...</div><div class="ttdef"><b>Definition:</b> <a href="net__env__simulator_8hpp_source.html#l00067">net_env_simulator.hpp:70</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1asio_1_1Node_html"><div class="ttname"><a href="classflow_1_1net__flow_1_1asio_1_1Node.html">flow::net_flow::asio::Node</a></div><div class="ttdoc">A subclass of net_flow::Node that adds the ability to easily and directly use net_flow sockets in gen...</div><div class="ttdef"><b>Definition:</b> <a href="asio_2node_8hpp_source.html#l00234">node.hpp:236</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1asio_1_1Node_html_a0e6b29f0ae35a832b0c3c75cf0b577ae"><div class="ttname"><a href="classflow_1_1net__flow_1_1asio_1_1Node.html#a0e6b29f0ae35a832b0c3c75cf0b577ae">flow::net_flow::asio::Node::set_async_task_engine</a></div><div class="ttdeci">void set_async_task_engine(util::Task_engine *target_async_task_engine)</div><div class="ttdoc">Overwrites the value to be returned by next async_task_engine().</div><div class="ttdef"><b>Definition:</b> <a href="asio_2node_8cpp_source.html#l00046">node.cpp:46</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1asio_1_1Node_html_a5b688a4071b8ad58a776de8d3816b757"><div class="ttname"><a href="classflow_1_1net__flow_1_1asio_1_1Node.html#a5b688a4071b8ad58a776de8d3816b757">flow::net_flow::asio::Node::m_target_task_engine</a></div><div class="ttdeci">util::Task_engine * m_target_task_engine</div><div class="ttdoc">See async_task_engine().</div><div class="ttdef"><b>Definition:</b> <a href="asio_2node_8hpp_source.html#l00575">node.hpp:575</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1asio_1_1Node_html_a778ffa52a73f455142da9497ca10734d"><div class="ttname"><a href="classflow_1_1net__flow_1_1asio_1_1Node.html#a778ffa52a73f455142da9497ca10734d">flow::net_flow::asio::Node::async_task_engine</a></div><div class="ttdeci">util::Task_engine * async_task_engine()</div><div class="ttdoc">Pointer (possibly null) for the flow::util::Task_engine used by any coming async I/O calls and inheri...</div><div class="ttdef"><b>Definition:</b> <a href="asio_2node_8cpp_source.html#l00040">node.cpp:40</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1asio_1_1Node_html_a7db28ab33b1a9afcdcd1884e08f33bee"><div class="ttname"><a href="classflow_1_1net__flow_1_1asio_1_1Node.html#a7db28ab33b1a9afcdcd1884e08f33bee">flow::net_flow::asio::Node::Node</a></div><div class="ttdeci">Node(log::Logger *logger, util::Task_engine *target_async_task_engine, const util::Udp_endpoint &amp;low_lvl_endpoint, Net_env_simulator *net_env_sim=0, Error_code *err_code=0, const Node_options &amp;opts=Node_options())</div><div class="ttdoc">Constructs Node.</div><div class="ttdef"><b>Definition:</b> <a href="asio_2node_8cpp_source.html#l00029">node.cpp:29</a></div></div>
<div class="ttc" id="alog_8hpp_html_a325fdd4b5cf0be49b37d3b7b7c29070d"><div class="ttname"><a href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a></div><div class="ttdeci">#define FLOW_LOG_INFO(ARG_stream_fragment)</div><div class="ttdoc">Logs an INFO message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...</div><div class="ttdef"><b>Definition:</b> <a href="log_8hpp_source.html#l00197">log.hpp:197</a></div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_1_1asio_html"><div class="ttname"><a href="namespaceflow_1_1net__flow_1_1asio.html">flow::net_flow::asio</a></div><div class="ttdoc">Contains classes that add boost.asio integration to the main Flow-protocol classes such as net_flow::...</div><div class="ttdef"><b>Definition:</b> <a href="asio_2node_8cpp_source.html#l00024">node.cpp:25</a></div></div>
<div class="ttc" id="anamespaceflow_1_1util_html_ac3e89a8a271b0ddc76ac2a0ce488dea4"><div class="ttname"><a href="namespaceflow_1_1util.html#ac3e89a8a271b0ddc76ac2a0ce488dea4">flow::util::Task_engine</a></div><div class="ttdeci">boost::asio::io_context Task_engine</div><div class="ttdoc">Short-hand for boost.asio event service, the central class of boost.asio.</div><div class="ttdef"><b>Definition:</b> <a href="util__fwd_8hpp_source.html#l00135">util_fwd.hpp:135</a></div></div>
<div class="ttc" id="anamespaceflow_1_1util_html_af1b28edb7bad743c1c77f6b982cc3196"><div class="ttname"><a href="namespaceflow_1_1util.html#af1b28edb7bad743c1c77f6b982cc3196">flow::util::Udp_endpoint</a></div><div class="ttdeci">boost::asio::ip::udp::endpoint Udp_endpoint</div><div class="ttdoc">Short-hand for the UDP endpoint (IP/port) type.</div><div class="ttdef"><b>Definition:</b> <a href="util__fwd_8hpp_source.html#l00208">util_fwd.hpp:208</a></div></div>
<div class="ttc" id="anamespaceflow_html_a29eaaa9d0fac4ce87d8b969222dbed09"><div class="ttname"><a href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">flow::Error_code</a></div><div class="ttdeci">boost::system::error_code Error_code</div><div class="ttdoc">Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...</div><div class="ttdef"><b>Definition:</b> <a href="common_8hpp_source.html#l00508">common.hpp:508</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node__options_html"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node__options.html">flow::net_flow::Node_options</a></div><div class="ttdoc">A set of low-level options affecting a single Flow Node, including Peer_socket objects and other obje...</div><div class="ttdef"><b>Definition:</b> <a href="options_8hpp_source.html#l00448">options.hpp:449</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 28 2025 22:55:35 for Flow by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
